import turtle
import time

# 设置画布
screen = turtle.Screen()
screen.title("小僵尸")
screen.bgcolor("white")

# 创建画笔
zombie = turtle.Turtle()
zombie.speed(3)  # 绘制速度：1慢，10快，0最快
zombie.pensize(3)  # 画笔粗细

# 绘制头部
def draw_head():
    zombie.penup()
    zombie.goto(0, 100)
    zombie.pendown()
    zombie.color("green")
    zombie.begin_fill()
    zombie.circle(80)  # 头部大小
    zombie.end_fill()

# 绘制眼睛
def draw_eyes():
    # 左眼
    zombie.penup()
    zombie.goto(-30, 150)
    zombie.pendown()
    zombie.color("white")
    zombie.begin_fill()
    zombie.circle(15)
    zombie.end_fill()
    
    # 左眼瞳孔
    zombie.penup()
    zombie.goto(-30, 150)
    zombie.pendown()
    zombie.color("black")
    zombie.begin_fill()
    zombie.circle(7)
    zombie.end_fill()
    
    # 右眼
    zombie.penup()
    zombie.goto(30, 150)
    zombie.pendown()
    zombie.color("white")
    zombie.begin_fill()
    zombie.circle(15)
    zombie.end_fill()
    
    # 右眼瞳孔
    zombie.penup()
    zombie.goto(30, 150)
    zombie.pendown()
    zombie.color("black")
    zombie.begin_fill()
    zombie.circle(7)
    zombie.end_fill()

# 绘制嘴巴
def draw_mouth():
    zombie.penup()
    zombie.goto(-20, 100)
    zombie.pendown()
    zombie.color("black")
    zombie.width(2)
    zombie.goto(20, 100)  # 嘴巴
    zombie.penup()
    zombie.goto(-10, 90)
    zombie.pendown()
    zombie.goto(10, 90)   # 牙齿

# 绘制身体
def draw_body():
    zombie.penup()
    zombie.goto(0, 20)
    zombie.pendown()
    zombie.color("green")
    zombie.begin_fill()
    zombie.goto(0, -80)   # 身体长度
    zombie.goto(-50, -150)
    zombie.goto(50, -150)
    zombie.goto(0, -80)
    zombie.end_fill()

# 绘制手臂
def draw_arms():
    # 左手臂
    zombie.penup()
    zombie.goto(0, 0)
    zombie.pendown()
    zombie.color("green")
    zombie.begin_fill()
    zombie.goto(-70, -30)
    zombie.goto(-90, -20)
    zombie.goto(-20, 10)
    zombie.goto(0, 0)
    zombie.end_fill()
    
    # 右手臂
    zombie.penup()
    zombie.goto(0, 0)
    zombie.pendown()
    zombie.color("green")
    zombie.begin_fill()
    zombie.goto(70, -30)
    zombie.goto(90, -20)
    zombie.goto(20, 10)
    zombie.goto(0, 0)
    zombie.end_fill()

# 绘制腿
def draw_legs():
    # 左腿
    zombie.penup()
    zombie.goto(-20, -150)
    zombie.pendown()
    zombie.color("green")
    zombie.begin_fill()
    zombie.goto(-30, -220)
    zombie.goto(-10, -220)
    zombie.goto(-10, -150)
    zombie.goto(-20, -150)
    zombie.end_fill()
    
    # 右腿
    zombie.penup()
    zombie.goto(20, -150)
    zombie.pendown()
    zombie.color("green")
    zombie.begin_fill()
    zombie.goto(30, -220)
    zombie.goto(10, -220)
    zombie.goto(10, -150)
    zombie.goto(20, -150)
    zombie.end_fill()

# 绘制衣服
def draw_clothes():
    zombie.penup()
    zombie.goto(0, -10)
    zombie.pendown()
    zombie.color("blue")
    zombie.width(2)
    zombie.goto(0, -70)
    zombie.penup()
    zombie.goto(-40, -30)
    zombie.pendown()
    zombie.goto(40, -30)

# 组合所有部分绘制小僵尸
def draw_zombie():
    draw_head()
    draw_eyes()
    draw_mouth()
    draw_body()
    draw_arms()
    draw_legs()
    draw_clothes()
    
    # 隐藏画笔
    zombie.hideturtle()

# 执行绘制
draw_zombie()

# 保持窗口打开
turtle.done()
